<template>
  <div class="m-products-detail m-container">
    <el-image
      class="sku-img"
      fit="cover"
      :src="productsDetail.coverImage"
      :preview-src-list="[productsDetail.coverImage]"
      lazy
      :alt="productsDetail.subTypeName"
    ></el-image>
    <!-- 设备title、规格参数 -->
    <div class="info-title">{{ productsDetail.skuName }}</div>
    <div class="sku-desc">{{ productsDetail.categoryName }}</div>
    <div class="view-title" v-if="productsDetail.categoryFeatureList.length">{{ $t("features") }}</div>
    <div class="product-features" v-if="productsDetail.categoryFeatureList.length">
      <div class="features-item" v-for="item in productsDetail.categoryFeatureList" :key="item.id">
        <p>{{ item.featureTitle }}</p>
        <span>{{ item.featureContent }}</span>
      </div>
    </div>
    <div class="view-title">{{ $t("specsCompare") }}</div>
    <div class="compare-params">
      <div class="params-item" v-for="item in productsDetail.kuSpecsList" :key="item.id">
        <div class="item-canshu" :title="item.specsName">{{ item.specsName }}</div>
        <div class="item-canshu" :title="item.specsValue">{{ item.specsValue }}</div>
      </div>
    </div>
    <!-- WhatsApp -->
    <!-- <WhatsAppM v-if="locale == 'en-US'" /> -->
    <!-- 底部信息 -->
    <FooterM></FooterM>
  </div>
</template>

<script>
import { mapState } from "vuex"
export default {
  name: "M-productsDetail",
  layout: "mobile",
  data() {
    return {}
  },
  head() {
    return {
      title: `【${this.productsDetail.skuName}】-${this.productsDetail.skuName}${this.$i18n.t("detailHeadTitle")}`,
      meta: [
        {
          hid: "keywords",
          name: "keywords",
          content: this.$i18n.t("haeaKeyContent")
        },
        {
          hid: "description",
          name: "description",
          content: this.$i18n.t("haeaDecContent")
        },
        {
          property: "og:title",
          content: `${this.productsDetail.skuName}`
        },
        {
          property: "og:description",
          content: this.$i18n.t("haeaDecContent")
        },
        {
          property: "og:url",
          content: `${this.hostUrl}${this.routeUrl}`
        },
        {
          property: "og:image",
          content: `${this.productsDetail.coverImage}`
        }
      ]
    }
  },
  async asyncData({ app, params }) {
    let paramsRes = params.detailParams
    console.log("paramsRes", paramsRes)
    let skuId = paramsRes //设备ID
    let productsDetail = {} //设备详情
    try {
      let { data } = await app.$api.skuDetails({ skuId })
      productsDetail = data
    } catch (error) {
      console.log("error", error)
    }
    return {
      productsDetail
    }
  },
  props: {},
  computed: { ...mapState(["locale"]) },
  watch: {},
  async mounted() {
    this.getPoint()
  },
  methods: {
    async getPoint() {
      let params = await this.$optionPoint.sendUrl(window, navigator, document)
      this.$api.burySave({ ...params }).then((res) => {})
    }
  }
}
</script>

<style lang="scss" scoped>
.m-products-detail {
  .sku-img {
    width: 100%;
    height: 100%;
    margin-top: 225px;
  }
  .info-title {
    font-size: 112px;
    font-weight: 500;
    color: #fb463f;
    line-height: 122px;
  }
  .sku-desc {
    font-size: 92px;
    font-weight: 500;
    color: #707070;
    line-height: 92px;
    margin-top: 50px;
  }
  .view-title {
    font-family: PingFangSC, PingFang SC;
    font-weight: 600;
    font-size: 82px;
    color: #333;
    text-align: center;
    margin-top: 100px;
  }
  .product-features {
    margin-top: 80px;
    .features-item {
      padding: 50px;
      box-sizing: border-box;
      margin-top: 50px;
      box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.1);
      p {
        font-weight: 700;
        font-size: 82px;
        color: #000;
        margin-bottom: 40px;
      }
      span {
        font-weight: 500;
        font-size: 72px;
        color: #504f4f;
        line-height: 112px;
      }
    }
  }
  .compare-params {
    padding: 50px 40px;
    box-sizing: border-box;
    margin-top: 80px;
    box-shadow: 0px 4px 20px 0px rgba(0, 0, 0, 0.1);
    .params-item {
      display: flex;
      align-items: center;
      justify-content: space-between;
      .item-canshu {
        width: 48%;
        height: 140px;
        line-height: 140px;
        font-size: 72px;
        border: #333;
        border-bottom: 1px solid #d9d9d9;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
      }
    }
  }
}
</style>
